home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Network Support Library
/
RoseWare - Network Support Library.iso
/
logbatch
/
short.exe
/
SHORTE.INC
< prev
Wrap
Text File
|
1993-07-04
|
1KB
|
34 lines
; This routine expects three DOS environment variables:
; LONG, LENGTH, TRUNCATE.
; LONG contains original string
; SHORT on exit contains LENGTH characters of LONG,
; either by TRUNCATE on the LEFT or on the RIGHT, depending on the
; setting of TRUNCATE.
;
; This code is a modification of HOMMAP.INC and is inspired by SHORTEN.EXE
; and has been lightly tested under nw3.11 from msdos 5.0.
; It is intended to be used a bit like a subroutine.
TEMP SET WORKSTR = "<%LONG>"
TEMP SET COUNTER = "0"
; Count length of LONG
COUNTLOOP:
IF <WORKSTR> == "" THEN GOTO COUNTDONE
TEMP SET COUNTER = <COUNTER> + "1"
TEMP SET WORKSTR = <WORKSTR> >> 1
GOTO COUNTLOOP
COUNTDONE:
; Check to see if length is more than LENGTH
SET SHORT="<%LONG>"
IF VALUE <COUNTER> <= VALUE <LENGTH> THEN GOTO TRUNCDONE
; Yes, it's more than LENGTH, chop it off
TEMP SET COUNTER = <COUNTER> - <LENGTH>
TRUNCLOOP:
IF VALUE <COUNTER> == "0" THEN GOTO TRUNCDONE
TEMP SET COUNTER = <COUNTER> - "1"
if <TRUNCATE>=="LEFT" SET SHORT= "%<SHORT>" << 1
if <TRUNCATE>=="RIGHT" SET SHORT="%<SHORT>" >> 1
GOTO TRUNCLOOP
TRUNCDONE:
; Now SHORT has been shorten to LENGTH characters or less